package com.ruoyi.web.controller.tool;

import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.*;

/**
 * 功能:通用的静态工具函数(用于日期和时间处理)
 * <p>
 * Description: 通用工具类
 * </p>
 */

public class DateTimeUtils {

	public final static String DATE_FORMAT_YYYYMMDD = "yyyyMMdd";
	public final static String DATE_FORMAT_YYYY_MM_DD = "yyyy-MM-dd";
	public final static String DATE_FORMAT_MMDD = "MMdd";
	public final static String DATETIME_FORMAT_HHMMSS = "HHmmss";
	public final static String DATETIME_FORMAT_HHMM = "HHmm";
	public final static String DATETIME_FORMAT_MMDDHHMMSS = "MMddHHmmss";
	public final static String DATETIME_FORMAT_HHMMSSSSS = "HHmmssSSS";
	public final static String DATETIME_FORMAT_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
	public final static String DATETIME_FORMAT_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
	public final static String DATETIME_FORMAT_YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
	public final static String DATETIME_FORMAT_YYYYMMDDHH = "yyyyMMddHH";
	public final static String DATETIME_FORMAT_YYYYMMDDHHMMSSSSS = "yyyyMMddHHmmssSSS";
	public final static String DATETIME_FORMAT_YYYY = "yyyy";
	public final static String DATETIME_FORMAT_YY = "yy";
	public final static String DATETIME_FORMAT_YYYY_MM_DD_CN = "yyyy年MM月dd日";
	public final static String DATETIME_FORMAT_HH_MM_SS = "HH:mm:ss";
	public final static String DATETIME_FORMAT_HH_MM = "HH:mm";
	public final static String DATE_FORMAT_YYYYMM = "yyyyMM";
	public final static String DATE_FORMAT_YYMM = "yyMM";
	public final static String DATE_FORMAT_YYMMDD = "yyMMdd";
	/** AOP Date默认时区 **/
	public static final String DATE_TIMEZONE = "GMT+8";

	private static final String minute = "60";
	private static final String second = "3600";


	/**
	 * 根据总金额 算出 标准金额/小时 的小时分钟
	 * @param total
	 * @param standard
	 * @return
	 */
	public static String MoneyChangeTime(BigDecimal total, BigDecimal standard){
		BigDecimal bigDecimal = total.divide(standard,0,BigDecimal.ROUND_DOWN).multiply(new BigDecimal(minute));
		BigDecimal decimal = total.remainder(standard).divide(standard,10,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(minute))
				.setScale(0,BigDecimal.ROUND_HALF_UP);
		int liveTimeTotle = bigDecimal.add(decimal).intValue();
		int hours = (int) Math.floor(liveTimeTotle / 60);
		int minute = liveTimeTotle % 60;
		double decimal1 = Double.parseDouble(String.valueOf(hours).concat(".").concat(String.valueOf(minute)));
		return String.valueOf(decimal1).replaceAll("\\.",":")+":00";
	}

	/**
	 * LocalTime 类型转换为秒
	 * @param localTime
	 * @return
	 */
	public static int changeSecond(LocalTime localTime){
		int hour = localTime.getHour();
		int minute = localTime.getMinute();
		int second = localTime.getSecond();
		int secondTotal = 0;
		if (0==hour && 0==minute && 0==second){
			System.out.println("返回0");
		}
		if (hour != 0){
			secondTotal = hour * 60 * 60;
		}
		if (minute != 0){
			secondTotal = secondTotal +  minute * 60;
		}
		if (second != 0){
			secondTotal = secondTotal +  second;
		}
		return secondTotal;
	}

	/**
	 * BigDecimal 转 时分
	 * 3 == 03:00
	 * @param bigDecimal
	 * @return
	 */
	public static LocalTime BigSecondTime(BigDecimal bigDecimal){
		StringBuilder time = new StringBuilder(String.valueOf(bigDecimal));
		if (time.length() == 1){
			time.insert(0,"0").append(":00");
		}
		if (time.length() == 2){
			time.append(":00");
		}
		return LocalTime.parse(time);
	}

	/**
	 * 获得指定日期的后N天
	 * @return
	 */
	public static Date getSpecifiedDayAfter(Date date, int num) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day = c.get(Calendar.DATE);
		c.set(Calendar.DATE, day + num);
		return c.getTime();
	}

	/**
	 * 获取近几天的日期
	 */
	public static List<String> getSevenDate(int t){
		List<String> list = new ArrayList<>(t);
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_YYYY_MM_DD);
		Calendar c = null;
		for (int i=0;i<t;i++){
			c=Calendar.getInstance();
			c.add(Calendar.DAY_OF_MONTH, -i);
			list.add(sdf.format(c.getTime()));
		}
		return list;
	}

	/**
	 * 获得指定日期的前N天
	 * @return
	 */
	public static Date getSpecifiedDayBefore(Date date, int num) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day = c.get(Calendar.DATE);
		c.set(Calendar.DATE, day - num);
		return c.getTime();
	}

	public static Date getSpecifiedMmBefore(Date date, int num) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int min = c.get(Calendar.MINUTE);
		c.set(Calendar.MINUTE, min - num);
		return c.getTime();
	}

	/**
	 * 获得指定日期的后N小时
	 * @return
	 */
	public static Date getSpecifiedHourAfter(Date date, int num) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		c.set(Calendar.HOUR_OF_DAY, hour + num);
		return c.getTime();
	}

	public static Date getSpecifiedHourBefore(Date date, int num) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		c.set(Calendar.HOUR_OF_DAY, hour - num);
		return c.getTime();
	}

	/**
	 * 日期间隔是否大于指定数
	 *
	 * @param begin
	 * @param end
	 * @param timeinmill
	 * @return
	 */
	public static boolean isAfterInMill(Date begin, Date end, long timeinmill) {
		long begininmill = begin.getTime();
		long endinmill = end.getTime();
		if (endinmill - begininmill > timeinmill) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 比较两个时间大小
	 *
	 * @param first
	 * @param second
	 * @return <0: first<second =0: first=second >0: first>second
	 */
	public static int compareTwoDate(Date first, Date second) {
		Calendar c1 = Calendar.getInstance();
		Calendar c2 = Calendar.getInstance();

		c1.setTime(first);
		c2.setTime(second);

		return c1.compareTo(c2);
	}

	/**
	 * 按日期比较两个时间大小
	 *
	 * @param first
	 * @param second
	 * @return <0: first<second =0: first=second >0: first>second
	 */
	public static int compareDate(Date first, Date second) {
		Calendar c1 = Calendar.getInstance();
		Calendar c2 = Calendar.getInstance();

		c1.setTime(first);
		c2.setTime(second);

		int day1 = c1.get(Calendar.YEAR) * 1000 + c1.get(Calendar.DAY_OF_YEAR);
		int day2 = c2.get(Calendar.YEAR) * 1000 + c2.get(Calendar.DAY_OF_YEAR);

		return day1 - day2;
	}

	/**
	 * 取得当前日期所在周的第一天
	 *
	 * @param date
	 * @return
	 */
	public static Date getFirstDayOfWeek(Date date) {
		Calendar c = new GregorianCalendar();
		c.setFirstDayOfWeek(Calendar.MONDAY);
		c.setTime(date);
		c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); // Monday
		return c.getTime();
	}

	/**
	 * 取得当前日期所在周的最后一天
	 *
	 * @param date
	 * @return
	 */
	public static Date getLastDayOfWeek(Date date) {
		Calendar c = new GregorianCalendar();
		c.setFirstDayOfWeek(Calendar.MONDAY);
		c.setTime(date);
		c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); // Sunday
		return c.getTime();
	}

	/**
	 * 计算日期增加或减少小时数后的日期
	 * @param date
	 * @return
	 */
	public static Date addHH(Date date, int i) {
		if (date == null)
			return null;
		Calendar c = new GregorianCalendar();
		c.setTime(date);
		c.add(Calendar.HOUR, i);
		return c.getTime();
	}

	/**
	 * 计算日期增加或减少分钟数后的日期
	 *
	 * @param date
	 * @return
	 */
	public static Date addMM(Date date, int i) {
		if (date == null)
			return null;
		Calendar c = new GregorianCalendar();
		c.setTime(date);
		c.add(Calendar.MINUTE, i);
		return c.getTime();
	}

	/**
	 * 计算日期增加或减少秒数后的日期
	 *
	 * @param date
	 * @return
	 */
	public static Date addSS(Date date, int i) {
		if (date == null)
			return null;
		Calendar c = new GregorianCalendar();
		c.setTime(date);
		c.add(Calendar.SECOND, i);
		return c.getTime();
	}

	/**
	 * 计算日期增加减少天数后的日期
	 *
	 * @param date
	 * @return
	 */
	public static Date addDate(Date date, int i) {
		if (date == null)
			return null;
		Calendar c = new GregorianCalendar();
		c.setTime(date);
		c.add(Calendar.DATE, i);
		return c.getTime();
	}

	/**
	 * 计算日期增加减少月数后的日期
	 *
	 * @param date
	 * @return
	 */
	public static Date addMonth(Date date, int i) {
		if (date == null)
			return null;
		Calendar c = new GregorianCalendar();
		c.setTime(date);
		c.add(Calendar.MONTH, i);
		return c.getTime();
	}

	/**
	 * 获取当前时间的月份
	 */
	public static String getMonth() {
		Calendar c = Calendar.getInstance();
		int mon = c.get(Calendar.MONTH) + 1;

		return String.format("%02d", mon);
	}

	/**
	 * 根据日期参数，获取字符串月份
	 */
	public static String getMonthByDate(Date date) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int mon = c.get(Calendar.MONTH) + 1;

		return String.format("%02d", mon);
	}

	/**
	 * 计算日期增加减少年数后的日期
	 *
	 * @param date
	 * @return
	 */
	public static Date addYear(Date date, int i) {
		if (date == null)
			return null;
		Calendar c = new GregorianCalendar();
		c.setTime(date);
		c.add(Calendar.YEAR, i);
		return c.getTime();
	}

	/**
	 * 获取当前时间的年份
	 */
	public static String getYear() {
		Calendar c = Calendar.getInstance();
		int year = c.get(Calendar.YEAR);

		return String.valueOf(year);
	}

	/**
	 * 根据日期参数，获取字符串年份
	 */
	public static String getYearByDate(Date date) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int year = c.get(Calendar.YEAR);

		return String.valueOf(year);
	}

	/**
	 * 获得当前时间字符串
	 *
	 * @param formatStr
	 *            日期格式
	 * @return string yyyy-MM-dd
	 */
	public static String getNowDateStr(String formatStr) {
		SimpleDateFormat format = new SimpleDateFormat(formatStr);
		return format.format(getNowDate());
	}

	/**
	 * 获得系统当前时间
	 *
	 * @return Date
	 */
	public static Date getNowDate() {
		Calendar c = Calendar.getInstance();
		return c.getTime();
	}

	/**
	 * 把日期按照指定格式的转化成字符串
	 *
	 * @param date
	 *            日期对象
	 * @param formatStr
	 *            日期格式
	 * @return 字符串式的日期,格式为：yyyy-MM-dd HH:mm:ss
	 */
	public static String getDateTimeToString(Date date, String formatStr) {
		SimpleDateFormat format = new SimpleDateFormat(formatStr);
		return format.format(date);
	}

	/**
	 * 把日期字符串转化成指定格式的日期对象
	 *
	 * @param dateStr
	 *            日期字符串
	 * @param formatStr
	 *            日期格式
	 * @return Date类型的日期
	 * @throws Exception
	 */
	public static Date getStringToDateTime(String dateStr, String formatStr) throws Exception {
		SimpleDateFormat format = new SimpleDateFormat(formatStr);
		Date date = null;

		date = format.parse(dateStr);
		return date;
	}

	/**
	 * 把日期字符串转化成指定格式的日期对象，如果异常则返回null
	 *
	 * @param dateStr
	 *            日期字符串
	 * @param formatStr
	 *            日期格式
	 * @return Date类型的日期
	 * @throws Exception
	 */
	public static Date getStringToDateTimeExceptionNull(String dateStr, String formatStr) {
		Date date = null;

		if (StringUtils.isBlank(dateStr)) {
			return date;
		}

		SimpleDateFormat format = new SimpleDateFormat(formatStr);

		try {
			date = format.parse(dateStr);
		} catch (ParseException e) {
			return null;
		}
		return date;
	}

	/**
	 * 校验日期与格式是否一致
	 *
	 * @param dttm
	 * @param format
	 * @return
	 */
	public static boolean isDate(String dttm, String format) {
		if (dttm == null || dttm.isEmpty() || format == null || format.isEmpty()) {
			return false;
		}

		if (format.replaceAll("'.+?'", "").indexOf("y") < 0) {
			format += "/yyyy";
			DateFormat formatter = new SimpleDateFormat("/yyyy");
			dttm += formatter.format(new Date());
		}

		DateFormat formatter = new SimpleDateFormat(format);
		formatter.setLenient(false);
		ParsePosition pos = new ParsePosition(0);
		Date date = formatter.parse(dttm, pos);

		if (date == null || pos.getErrorIndex() > 0) {
			return false;
		}
		if (pos.getIndex() != dttm.length()) {
			return false;
		}

		if (formatter.getCalendar().get(Calendar.YEAR) > 9999) {
			return false;
		}

		return true;
	}

	/**
	 * 获得当前时间的i分钟后（或前，用负数表示）的时间
	 *
	 * @param i
	 * @return
	 */
	public static String addMM(int i) {
		Date currTime = addMM(getNowDate(), i);
		SimpleDateFormat format = new SimpleDateFormat(DATETIME_FORMAT_YYYY_MM_DD_HH_MM_SS);
		return format.format(currTime);
	}

	/**
	 * 获得某个时间的i分钟后（或前，用负数表示）的时间
	 *
	 * @param i
	 * @return
	 */
	public static String dateAddMM(Date date, int i) {
		Date currTime = addMM(date, i);
		SimpleDateFormat format = new SimpleDateFormat(DATETIME_FORMAT_YYYY_MM_DD_HH_MM_SS);
		return format.format(currTime);
	}

	/**
	 * 获得某个时间的i秒后（或前，用负数表示）的时间
	 *
	 * @param i
	 * @return
	 */
	public static String dateAddSS(Date date, int i) {
		Date currTime = addSS(date, i);
		SimpleDateFormat format = new SimpleDateFormat(DATETIME_FORMAT_YYYY_MM_DD_HH_MM_SS);
		return format.format(currTime);
	}

	/**
	 * @param date
	 *            获取给定日期的起初时间 XX-XX-XX 00:00:00:0
	 * @return date
	 */
	public static Date getBegin(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		return calendar.getTime();
	}

	/**
	 * @param date
	 *            获取给定日期前后的起初时间 XX-XX-XX 00:00:00:0
	 * @return date
	 */
	public static Date getStartTimeOfDay(Date date, int day) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.set(Calendar.HOUR_OF_DAY, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MILLISECOND, 0);
		cal.add(Calendar.DAY_OF_MONTH, day);

		return cal.getTime();
	}

	/**
	 * @param date
	 *            获取给定日期的结束时间 XX-XX-XX 23:59:59
	 * @return date
	 */
	public static Date getEnd(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 23);
		calendar.set(Calendar.MINUTE, 59);
		calendar.set(Calendar.SECOND, 59);
		return calendar.getTime();
	}

	/**
	 * @param date
	 *            获取给定日期前后的结束时间 XX-XX-XX 23:59:59
	 * @return date
	 */
	public static Date getEndTimeOfDay(Date date, int day) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 23);
		calendar.set(Calendar.MINUTE, 59);
		calendar.set(Calendar.SECOND, 59);
		calendar.add(Calendar.DAY_OF_MONTH, day);
		return calendar.getTime();
	}

	/**
	 * @param date
	 *            获取给定日期的结束时间 XX-XX-XX 23:59:59:999
	 * @return date
	 */
	public static Date getEndTime(Date date) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 23);
		calendar.set(Calendar.MINUTE, 59);
		calendar.set(Calendar.SECOND, 59);
		calendar.set(Calendar.MILLISECOND, 999);
		return calendar.getTime();
	}

	public static boolean isBeforeToday(Date theDay) {
		Calendar cNow = Calendar.getInstance();
		int iYear = cNow.get(Calendar.YEAR);
		int iDay = iYear * 1000 + cNow.get(Calendar.DAY_OF_YEAR);

		Calendar cDay = Calendar.getInstance();
		cDay.setTime(theDay);
		int iTheYear = cDay.get(Calendar.YEAR);
		int iTheDay = iTheYear * 1000 + cDay.get(Calendar.DAY_OF_YEAR);

		return iTheDay < iDay;
	}

	public static boolean isToday(Date theDay) {
		Calendar cNow = Calendar.getInstance();
		int iYear = cNow.get(Calendar.YEAR);
		int iDay = cNow.get(Calendar.DAY_OF_YEAR);

		Calendar cDay = Calendar.getInstance();
		cDay.setTime(theDay);
		int iTheYear = cDay.get(Calendar.YEAR);
		int iTheDay = cDay.get(Calendar.DAY_OF_YEAR);

		return (iTheYear == iYear) && (iTheDay == iDay);
	}

	public static boolean isToday240000(Date theDay) {
		Date tomorrow = getSpecifiedDayAfter(getNowDate(), 1);

		String strDate = getDateTimeToString(tomorrow, DATE_FORMAT_YYYYMMDD);
		strDate += "000000";

		Date target = getStringToDateTimeExceptionNull(strDate, DATETIME_FORMAT_YYYYMMDDHHMMSS);

		return compareTwoDate(theDay, target) == 0;
	}

	/**
	 * 计算两个日期之间的相差的天数. 计算方式：second - first
	 * <p>
	 * Create Date: 2015年1月22日
	 * </p>
	 *
	 * @param smdate
	 *            较小的时间
	 * @param bdate
	 *            较大的时间
	 * @return 相差的天数
	 */
	public static int daysBetween(Date smdate, Date bdate) {
		int result = 0;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		try {
			smdate = sdf.parse(sdf.format(smdate));
			bdate = sdf.parse(sdf.format(bdate));
			Calendar cal = Calendar.getInstance();
			cal.setTime(smdate);
			long time1 = cal.getTimeInMillis();
			cal.setTime(bdate);
			long time2 = cal.getTimeInMillis();
			long between_days = (time2 - time1) / (1000 * 3600 * 24);
			result = Integer.parseInt(String.valueOf(between_days));
		} catch (ParseException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

		return result;
	}

	/**
	 * 计算两个日期之间的相差的秒数. 计算方式：second - first
	 *
	 * @param smdate
	 *            较小的时间
	 * @param bdate
	 *            较大的时间
	 * @return 相差的秒数
	 */
	public static int secondsBetween(Date smdate, Date bdate) {
		int result = 0;
		try {
			Calendar cal = Calendar.getInstance();
			cal.setTime(smdate);
			long time1 = cal.getTimeInMillis();
			cal.setTime(bdate);
			long time2 = cal.getTimeInMillis();
			long between_min = (time2 - time1) / 1000;
			result = Integer.parseInt(String.valueOf(between_min));
		} catch (Exception e) {
			e.printStackTrace();
		}

		return result;
	}

	/**
	 * 将时间戳转换为date
	 * <p>
	 * Create Date: 2015年3月30日
	 * </p>
	 *
	 * @param seconds
	 * @return
	 */
	public static Date getTimestampToDate(long seconds) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(seconds);

		return calendar.getTime();
	}

	/**
	 * 判断时间是否落于某个区间内
	 * <p>
	 * Create Date: 2015年11月4日
	 * </p>
	 *
	 * @param date
	 * @param startTime
	 *            hh:mm:ss or hh:mm
	 * @param endTime
	 *            hh:mm:ss or hh:mm
	 * @return
	 */
	public static boolean isInTimeInterval(Date date, String startTime, String endTime) {
		int iStartTime = 0, iEndTime = 0, iTime = 0;
		try {
			if (startTime.length() <= 5) {
				startTime = startTime + ":00";
			}
			if (endTime.length() <= 5) {
				endTime = endTime + ":00";
			}
			startTime = startTime.replace(":", "");
			endTime = endTime.replace(":", "");

			iStartTime = Integer.parseInt(startTime);
			iEndTime = Integer.parseInt(endTime);

			iTime = Integer.parseInt(getDateTimeToString(date, DATETIME_FORMAT_HHMMSS));
		} catch (Exception e) {
			return false;
		}

		boolean result = false;
		if (iStartTime < iEndTime) {
			result = iStartTime <= iTime;
			result &= iTime <= iEndTime;
		} else {
			result = iStartTime <= (iTime + 240000);
			result &= iTime <= iEndTime;
		}
		return result;
	}


	public static int DateACompM(String startTime,String nowDate) throws Exception {
		long from = getStringToDateTime(startTime,DATETIME_FORMAT_YYYY_MM_DD_HH_MM_SS).getTime();
		long to = getStringToDateTime(nowDate,DATETIME_FORMAT_YYYY_MM_DD_HH_MM_SS).getTime();
		int minutes = (int) ((to - from)/(1000 * 60));
		return minutes;
	}

	/**
	 * 秒钟转时分秒
	 * @param str 秒
	 * @return 时分秒
	 */
	public static String secToTime(Object str) {
		int time = Integer.parseInt(str.toString());
		String timeStr = null;
		int hour = 0;
		int minute = 0;
		int second = 0;
		if (time <= 0) return "00分00秒";
		else {
			minute = time / 60;
			if (minute < 60) {
				second = time % 60;
				timeStr = unitFormat(minute) + "分" + unitFormat(second) + "秒";
			} else {
				hour = minute / 60;
				if (hour > 99) return "99时59分59秒";
				minute = minute % 60;
				second = time - hour * 3600 - minute * 60;
				timeStr = unitFormat(hour) + "时" + unitFormat(minute) + "分" + unitFormat(second) + "秒";
			}
		}
		return timeStr;
	}

	/**
	 * 保持两位数字
	 * @param i
	 * @return
	 */
	public static String unitFormat(int i) {
		String retStr = null;
		if (i >= 0 && i < 10) retStr = "0" + Integer.toString(i);
		else retStr = "" + i;
		return retStr;
	}



	/**
	 * 将秒数转换为时分秒的格式。
	 *
	 * @param seconds 秒数，整型数值
	 * @return 返回时分秒格式的字符串，如"02:23:45"
	 */
	public static String convertSecondsToTimeFormat(int seconds) {
		int hours = seconds / 3600; // 计算小时数
		int remainder = seconds % 3600; // 计算剩余秒数
		int minutes = remainder / 60; // 计算分钟数
		seconds = remainder % 60; // 计算剩余秒数

		// 使用String.format进行格式化，确保单个数字前补零
		return String.format("%02d小时%02d分钟%02d秒", hours, minutes, seconds);
	}

	public static void main(String[] args) {
		int secondsInput = 12913; // 示例秒数
		String timeFormat = convertSecondsToTimeFormat(secondsInput);
		System.out.println(timeFormat); // 输出转换后的时分秒格式
	}

}
